package com.two.lbms.service;

import com.two.lbms.dao.BookInfoMapper;
import com.two.lbms.dao.CollectionListMapper;
import com.two.lbms.dao.LendListMapper;
import com.two.lbms.dao.ReaderMapper;
import com.two.lbms.model.HomeData;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author hjx
 * @version V1.0
 * @Date 2023/8/3 17:49
 */
@Service
public class HomeService {

    @Resource
    private ReaderMapper readerMapper;
    @Resource
    private BookInfoMapper bookInfoMapper;
    @Resource
    private CollectionListMapper collectionListMapper;
    @Resource
    private LendListMapper lendListMapper;

    public HomeData getHomeData() {

        Integer readerCount = readerMapper.selectReaderCount();
        Integer bookCount = collectionListMapper.selectBookCount();
        Integer typeCount = bookInfoMapper.selectTypeCount();
        Integer lendCount = lendListMapper.selectLendCount();
        HomeData homeData = new HomeData();
        homeData.setReaderNum(readerCount);
        homeData.setBookNum(bookCount);
        homeData.setTypeNum(typeCount);
        homeData.setLendNum(lendCount);

        return homeData;

    }
}
